package com.example.admin.exception;

import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@Order(value = Ordered.HIGHEST_PRECEDENCE) //优先级，数字越小，优先级越高
//@Component
public class CustomerHandlerExceptionResolver implements HandlerExceptionResolver {

    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
        try{
            httpServletResponse.sendError(511, "我的最爱是茜茜");
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        return new ModelAndView();
    }
}
